﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LanDBom.Models.Procure
{
    public class Find_BOMini
    {
        LDbaseEntities LD = new LDbaseEntities();
        public List<BOMini> find_BOMini()
        {
            List<BOMini> listBOMini = LD.BOMini.ToList();
            return listBOMini;
        }

        public BOMini Gai(string BOM2_bian, string BOM2_chen, string BOM2_liao, string BOM2_wuliu)
        {
            var bomins = LD.BOMini.Where(a => a.BOM2_bian == BOM2_bian || a.BOM2_chen == BOM2_chen || a.BOM2_wuLiu == BOM2_wuliu || a.BOM2_liao == BOM2_liao).FirstOrDefault();
            return bomins;

        }
        public int Ingai(string bOM2_bian, string bOM2_chen, string bOM2_liao, string bOM2_wuliu)
        {
            var gsufhuhd = LD.BOMini.Where(a => a.BOM2_bian == bOM2_bian || a.BOM2_chen == bOM2_chen || a.BOM2_wuLiu == bOM2_wuliu || a.BOM2_liao == bOM2_liao).Select(s => s.BOM2_id).Count();
            return gsufhuhd;
        }

        public List<BOMini> B_findnext(string bOM2_wuLiu, string bOM2_liao,string names)
        {
            var bs = LD.BOMini.Where(s => s.BOM2_bian==names).ToList();
            if (bOM2_wuLiu!=""&&bOM2_wuLiu!=null)
            {
                bs = bs.Where(s => s.BOM2_wuLiu.Contains(bOM2_wuLiu)).ToList();
            }
            else if (bOM2_liao!=""&&bOM2_liao!=null)
            {
                bs = bs.Where(s=>s.BOM2_liao.Contains(bOM2_liao)).ToList();
            }
            return bs;
        }
        public List<BOMini> B_findnext2(string bOM2_wuLiu, string bOM2_liao, string names)
        {
            var bs = LD.BOMini.Include("Formation").Where(s => s.BOM2_bian == names&&s.BOM2_chen== "Leve0").ToList();
            if (bOM2_wuLiu != "" && bOM2_wuLiu != null)
            {
                bs = bs.Where(s => s.BOM2_wuLiu.Contains(bOM2_wuLiu)).ToList();
            }
            else if (bOM2_liao != "" && bOM2_liao != null)
            {
                bs = bs.Where(s => s.BOM2_liao.Contains(bOM2_liao)).ToList();
            }
            return bs;
        }
    }
}